<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<%@page import="com.framework.utils.ConfigUtil"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jqGird</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .ml10 {
            margin-left: 15px;
        }

    </style>

</head>

<body class="gray-bg" >
<div class="wrapper wrapper-content  animated fadeInRight" id="ccbb">
    <div class="row">
        <div class="col-sm-12">
            <div class="toolbar">
                <div id="toolbar">

                </div>
            </div>


            <span id="spancc" class="spancc"></span>
            <div class="row">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>搜索条件</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content" >
                        <div class="row">
                            <div class="col-md-2"><input placeholder="期数" id="search_qishu" class="form-control"></div>
                            <div class="col-md-2"><input placeholder="获奖人姓名" id="search_userName" class="form-control"></div>
                            <div class="col-md-1"><button id="btn_search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button></div>
                        </div>
                    </div>
                </div>
            </div>
            <table id="wheelRecordTablePagin"></table>
        </div>
    </div>
    </div>
</body>
    <script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
    <script>

    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <script type="text/javascript">
        var picPath='<%=ConfigUtil.get("OSSURL")%>';
        //初始化表格对象
        var $table = $('#wheelRecordTablePagin');
        $table.bootstrapTable({
            url: "${pageContext.request.contextPath}/wheel/showWheelRecord.ac",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",//必须的
            dataType: "json",
            pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
            height: ($(window).height()-100) ,
            //cardView:true,//是否自适应手机
            pagination: true, //分页
            // queryParamsType: "limit",
            singleSelect: false,
            cache:false,
            sortName:"name",
            search: false, //显示搜索框
            showColumns:false,
            showRefresh:false,
            showToggle:false,
           showPaginationSwitch:false,
            smartDisplay:true,
            detailView:false,
            toolbar:"#toolbar",
            queryParams: queryParams,//参数
            searchOnEnterKey:true,
            sidePagination: "server", //服务端处理分页
            columns: [
                {
                    visible:false,
                    field:'id'
                },
                {
                    title: '期数',
                    field: 'qishu',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '奖品',
                    field: 'wheelName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '获奖人',
                    field: 'userName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '领奖状态',
                    field: 'state',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function (value, row, index) {
                        if(value==0)
                        {return '<button onclick="doGetGoods(\''+row.id+'\')" class="btn btn-primary">未领取,点击领取</button>';}
                        else
                        {return '<font color="green">已领取</font>';}
                    }
                },
                {
                    title: '创建时间',
                    field: 'createTime',
                    align: 'center'
                }
              ]
        });

        /*
         搜索按钮
         */
        $("#btn_search").click(function(){
            $table.bootstrapTable('selectPage', 1);
            $table.bootstrapTable('refresh', queryParams);
        });

        /*
         传递的参数
         */
        function queryParams(params) {
            var name=$("#search_userName").val();
            var qishu=$("#search_qishu").val();
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,  //页面大小
                offset: params.offset, //页码
                pageindex:params.pageNumber,
                userName: name,
                qishu:qishu
            };
            return temp;
        }
        ///////////////////////////////////////////////////////////////toolbar///////////////////////////////////////

function doGetGoods(id)
{
            swal({
                title: "您确定要领取这条中奖记录吗",
                text: "领取后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "领取奖品",
                cancelButtonText:"取消",
                closeOnConfirm: false
            }, function () {
                //执行批量删除
                $.ajax( {
                    url:'${pageContext.request.contextPath}/wheel/doGetGoods.ac',// 跳转到 action
                    data:{
                        id :id
                    },
                    type:'post',
                    cache:false,
                    dataType:'json',
                    success:function(data) {
                        if(data=='success'){
                            swal("领取成功！", "您已经领取了这条中奖记录。", "success");
                            //当前表格刷新
                            $table.bootstrapTable('refresh');
                        }else{
                            swal("领取失败！", "未能领取", "error");
                        }
                    },
                    error : function() {
                        alert("异常！");
                    }
                });

            });


}
    </script>



</html>
